﻿
Imports xmlctrl
Imports xhtmlctrl
Imports webctrl

Public Class usclient
    Inherits cacheControlProcessor

    Public Const _pathidentity As String = "/usclient"
    Private config As configParser = Nothing
    Private ieClipboardPromptLink As String = Nothing

    Public Overrides Sub initial(Optional ByVal config As configParser = Nothing)
        MyBase.initial(config)
        assert(Not config Is Nothing, "usclient needs to initial with a valid config.")
        ieClipboardPromptLink = config.parameter(configNaming.urlshorten.name _
                                                 , configNaming.urlshorten.ieClipboardPromptLink _
                                                 , configNaming.defaultValue.urlshorten.ieClipboardPromptLink)
        Me.config = config
    End Sub

    Protected Overrides Function normalretiredticks() As Int64
        Return npos
    End Function

    Public Overrides Function pathidentity() As String
        Return _pathidentity
    End Function

    Protected Overloads Overrides Function processImpl(ByVal context As httpContext _
                                                       , ByRef control As xmlcontrol) As Boolean
        assert(Not context Is Nothing, "context is a nothing httpContext instance.")
        Dim page As xhtmlpage = Nothing
        page = generateXhtmlPage(context)

        page.title().text = context.string(stringId.USCLIENT_TITLE)
        page.addcsslink(cssrequest.generateCssfileLinkUrl("usclient.css"))

        Dim div As div = Nothing
        div = context.createControl(New div())
        page.body().addchild(div)

        Dim li As li = Nothing
        li = context.createControl(New li())
        li.text = context.string(stringId.USCLIENT_DOWNLOAD)
        div.addchild(li)

        Dim a As a = Nothing
        a = context.createControl(New a())
        a.text = context.string(stringId.USCLIENT_DOWNLOADLINK)
        a.href = usclientDownloadLink()
        div.addchild(a)

        Dim img As img = Nothing
        img = context.createControl(New img())
        img.src = staticrequest.generateStaticfileLinkUrl("download.png")
        div.addchild(img)

        div = context.createControl(New div())
        page.body().addchild(div)

        li = context.createControl(New li())
        li.text = context.string(stringId.USCLIENT_UNZIP)
        div.addchild(li)

        img = context.createControl(New img())
        img.src = staticrequest.generateStaticfileLinkUrl("start.png")
        div.addchild(img)

        div = context.createControl(New div())
        page.body().addchild(div)

        li = context.createControl(New li())
        li.text = context.string(stringId.USCLIENT_RUNNING)
        div.addchild(li)

        img = context.createControl(New img())
        img.src = staticrequest.generateStaticfileLinkUrl("running.png")
        div.addchild(img)

        div = context.createControl(New div())
        page.body().addchild(div)

        li = context.createControl(New li())
        li.text = context.string(stringId.USCLIENT_USECLIPBOARD)
        div.addchild(li)

        img = context.createControl(New img())
        img.src = staticrequest.generateStaticfileLinkUrl("clipboard.png")
        div.addchild(img)

        Dim cite As cite = Nothing
        cite = context.createControl(New cite())
        cite.text = context.string(stringId.USCLIENT_USECLIPBOARD_DETAIL)
        div.addchild(cite)

        div = context.createControl(New div())
        page.body().addchild(div)

        li = context.createControl(New li())
        li.text = context.string(stringId.USCLIENT_DRAGDROP)
        div.addchild(li)

        img = context.createControl(New img())
        img.src = staticrequest.generateStaticfileLinkUrl("dragdrop.png")
        div.addchild(img)

        cite = context.createControl(New cite())
        cite.text = context.string(stringId.USCLIENT_DRAGDROP_DETAIL)
        div.addchild(cite)

        div = context.createControl(New div())
        page.body().addchild(div)

        li = context.createControl(New li())
        li.text = context.string(stringId.USCLIENT_TO_ONLINE)
        div.addchild(li)

        img = context.createControl(New img())
        img.src = staticrequest.generateStaticfileLinkUrl("serve.png")
        div.addchild(img)

        cite = context.createControl(New cite())
        cite.text = context.string(stringId.USCLIENT_WRITE_TO_CLIPBOARD)
        div.addchild(cite)

        li = context.createControl(New li())
        li.text = context.string(stringId.USCLIENT_XMLAPI)
        div.addchild(li)

        img = context.createControl(New img())
        img.src = staticrequest.generateStaticfileLinkUrl("xmlapi.png")
        div.addchild(img)

        cite = context.createControl(New cite())
        cite.text = context.string(stringId.USCLIENT_XMLAPI_DETAIL)
        div.addchild(cite)

        cite = context.createControl(New cite())
        cite.text = context.string(stringId.USCLIENT_XMLAPI_FREE)
        div.addchild(cite)

        cite = context.createControl(New cite())
        cite.text = context.string(stringId.USCLIENT_XMLAPI_INUSE)
        div.addchild(cite)

        li = context.createControl(New li())
        li.text = context.string(stringId.USCLIENT_CONFIG)
        div.addchild(li)

        img = context.createControl(New img())
        img.src = staticrequest.generateStaticfileLinkUrl("usclientconfig.png")
        div.addchild(img)

        a = context.createControl(New a())
        a.text = context.string(stringId.USCLIENT_CLOSE_CLIPBOARD)
        a.href = ieClipboardPromptLink
        div.addchild(a)

        control = page
        Return True
    End Function
End Class
